package com.bckj.fastboot.iot.data.mysql.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bckj.fastboot.iot.common.dto.query.IotStatusDataQuery;
import com.bckj.fastboot.iot.common.dto.response.IotStatusDataResponse;
import com.bckj.fastboot.iot.data.mysql.entity.IotStatusData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

/**
 * IotStatusDataMapper
 *
 * @author wfc
 * @date 2025/9/30 11:24
 **/
@Mapper
public interface IotStatusDataMapper extends BaseMapper<IotStatusData> {

    @Select("""
        select * from iot_status_data where id=#{0}
        """)
    IotStatusDataResponse findById(Long id);

    @SelectProvider(type = IotStatusDataProvider.class, method = "findList")
    List<IotStatusDataResponse> findList(IotStatusDataQuery query);

    class IotStatusDataProvider {
        public String findList(IotStatusDataQuery query) {
            SQL sql = new SQL();
            sql.SELECT("*");
            sql.FROM("iot_status_data");
            listWhere(sql, query);
            return sql.toString();
        }

        private void listWhere(SQL sql, IotStatusDataQuery query) {

        }
    }
}
